home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com
- Newsgroups: comp.lang.c++
- Subject: Re: SOCKETS
- Date: 20 Jan 1996 23:15:24 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4drt2c$ig9@news1.usa.pipeline.com>
- NNTP-Posting-Host: pipe11.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Jan 20, 1996 18:57:12 in article <SOCKETS>,
- 'M.J.Thomsit-CSSE93@cs.bham.ac.uk (Mark J Thomsit)' wrote:
-
-
- >Is there a way to check if a socket is holding any data, without having to
-
- >wait
- >until some data appears, ?
- >
- You didn't specify the platform. If using raw BSD4.3 sockets on Unix,
- it's done by setting the socket options with the fcntl() system call:
-
- fcntl(fd, F_SETFL, FNDELAY);
-
- This makes your socket non-blocking. When you attempt to read
- from this socket, say by using the recv() system call, and it returns
- 0, you can verify that no data is available by checking the global
- errno variable for the value EWOULDBLOCK.
-
- With System V TLI, non-blocking IO is accomplished by specifying
- the O_NDELAY flag when opening the stream with t_open.
-
- In Winsock, you really should use asynchronous sockets where
- your program is notified whenever data 'comes in'. See docs
- on WSAAsyncSelect function.
- --
- Pete Grant
- Kalevi, Inc.
- Object Oriented Software Development
-